package app.displayTree.special.sub {
	import app.displayTree.analyze.DisplayTreeAnalyzeSupport;

	import copyengine.infoTree.meta.CESAnimationEachFrameInfoMeta;
	import copyengine.infoTree.meta.CESDisplayObjectMeta;
	import copyengine.infoTree.meta.OldCESRectangleMeta;

	import flash.display.DisplayObject;
	import flash.display.Sprite;
	import flash.geom.Matrix;
	import flash.geom.Rectangle;

	import org.as3commons.lang.StringUtils;

	public final class RectangleSpecialSymbol extends SpecialSymbolHandleBasic {

        private var mMaskMc:DisplayObject;

        public function RectangleSpecialSymbol() {
            super();
        }

        override protected function isCanHandleThisSpecialSymbolKey(_symbolKey:String):Boolean {
            return StringUtils.startsWithIgnoreCase(_symbolKey, "RE_") || StringUtils.startsWithIgnoreCase(_symbolKey, "MASK_");
        }

        override protected function initialize(_symbolKey:String, _symbol:DisplayObject):void {
            mMaskMc = _symbol;
        }

        override protected function doGenerateSpecialSymbolMeta(_symbol:Sprite, _support:DisplayTreeAnalyzeSupport):CESDisplayObjectMeta {
            var reMeta:OldCESRectangleMeta = new OldCESRectangleMeta();
            reMeta.name = _symbol.name;

            var symbolRe:Rectangle = _symbol.getBounds(_symbol.parent);

            var frameInfo:CESAnimationEachFrameInfoMeta = new CESAnimationEachFrameInfoMeta();
            var frameMatrix:Matrix = new Matrix();
            frameMatrix.translate(symbolRe.left, symbolRe.top);
            frameInfo.setMatrix(frameMatrix);
            reMeta.frameTransformMatrixArray.push(frameInfo);

            reMeta.width = symbolRe.width;
            reMeta.height = symbolRe.height;
            reMeta.alpha = _symbol.alpha;

            return reMeta;
        }

    }
}
